package com.luluteam.pushlib.util;

import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;

import com.luluteam.pushlib.constant.AppHolder;

/**
 * @author JJY
 * @date 2016/9/14
 */
public class SharedPreferencesUtil {
    private static SharedPreferences mySharedPreferences;
    private static final String SP_NAME = "PUSH_SDK";

    static {
        mySharedPreferences = AppHolder.appContext.getSharedPreferences(SP_NAME, Activity.MODE_PRIVATE);
    }

    public static void putString(Context context, String key, String value) {
        SharedPreferences.Editor editor = mySharedPreferences.edit();
        editor.putString(key, value);
        editor.apply();
    }

    public static void putBoolean(String key, boolean b) {
        SharedPreferences.Editor editor = mySharedPreferences.edit();
        editor.putBoolean(key, b);
        editor.apply();
    }

    public static String getString(Context context, String key) {
        String content = mySharedPreferences.getString(key, "");
        return content;
    }

    public static boolean getBoolean(String key) {
        return mySharedPreferences.getBoolean(key, false);
    }
}
